package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

@JsonApiResource(type = "evaluateexameranswer")
@Table(name = "tnb_evaluate_examer_answer")
@Entity
public class EvaluateExamerAnswer extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private EvaluateQuestion question;// 对应的问题

	private EvaluateAnswer answer;// 评估人所填答案

	private EvaluateResult result;// 评估id

	private Integer forRisk;

	private Integer selectFlag;// 1 选中 0未选中

	@Column(name = "select_flag")
	public Integer getSelectFlag() {
		return selectFlag;
	}

	public void setSelectFlag(Integer selectFlag) {
		this.selectFlag = selectFlag;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "answer_id", foreignKey = @ForeignKey(name = "null"))
	public EvaluateAnswer getAnswer() {
		return answer;
	}

	public void setAnswer(EvaluateAnswer answer) {
		this.answer = answer;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "result_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public EvaluateResult getResult() {
		return result;
	}

	public void setResult(EvaluateResult result) {
		this.result = result;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "question_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public EvaluateQuestion getQuestion() {
		return question;
	}

	public void setQuestion(EvaluateQuestion question) {
		this.question = question;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Transient
	public Integer getForRisk() {
		return forRisk;
	}

	public void setForRisk(Integer forRisk) {
		this.forRisk = forRisk;
	}

}
